/* address */
//定义城市数组
var coun=new Array(
					   new Array("成华区","武侯区","青羊区","锦江区","金牛区","龙泉驿区","青白江区","新都区","双流县","郫县","温江区","大邑县","金堂县","蒲                                 江县","新津县","都江堰市","彭州市","崇州市","邛崃市", "其他"),
					   new Array("自流井区","贡井区","大安区","沿滩区和荣县","富顺县","其他"),
					   new Array("东区","西区","仁和区","米易县","盐边县","其他"), 
					   new Array("江阳区","纳溪区","龙马潭区","泸县","合江县","叙永县","古蔺县","其他"),
					   new Array("旌阳区","中江县","罗江县","广汉市","绵竹市","什邡市","其他"), 
					   new Array("涪城区","游仙区","江油市","三台县","安县","平武县","梓潼县","盐亭县","北川羌族自治县","其他"),
					   new Array("利州区","元坝区","朝天区","旺苍县","青川县","剑阁县","苍溪县","其他"), 
					   new Array("船山区","安居区","蓬溪县","大英县","射洪县","其他"), 
					   new Array("市中区","东兴区","资中县","隆昌县","威远县","其他"), 
					   new Array("市中区","五通桥","沙湾","金口河4个区，犍为县","井研县","夹江县","沐川县","峨边彝族自治县",
					               "马边彝族自治县","峨眉山市","其他"),
					   new Array("顺庆区","高坪区","嘉陵区","南部县","仪陇县","西充县","蓬安县","营山县","阆中市","其他"),
					   new Array("东坡区","仁寿县","彭山县","洪雅县","丹棱县","青神县","其他"),
					   new Array("翠屏区","宜宾县","南溪县","江安县","长宁县","高县","珙县","筠连县","兴文县","屏山县","其他"),
					   new Array("广安区","岳池县","武胜县","邻水县","华蓥市","其他"),
					   new Array("通川区","达县","宣汉县","开江县","大竹县","渠县","万源市","其他"),
					   new Array("雨城区","芦山县","名山县","天全县","荥经县","宝兴县","汉源县","石棉县","其他"),
					   new Array("巴州区","通江县","南江县","平昌县","其他"),
					   new Array("雁江区","安岳县","乐至县，简阳市","其他"),
					   new Array("汶川县","理县","茂县","松潘县","金川县","黑水县","马尔康县","壤塘县","阿坝县","若尔盖县","红原县",
					              "九寨沟县","小金县"," 其他"),
					   new Array("康定县","丹巴县","炉霍县","九龙县","甘孜县","雅江县","新龙县","道孚县","白玉县","理塘县","德格县",
					              "乡城县","石渠县","稻城县","色达县","巴塘县","泸定县","得荣县","其他"),
					   new Array("西昌市","木里县","盐源县","德昌县","会理县","会东县","宁南县","普格县","布拖县","金阳县","昭觉县",
					               "喜德县","冕宁县","越西县","甘洛县","美姑县","雷波县","其他")
					   
					);
function scity(pname,cname,sf,cs){
	/*
		自定义函数中pname代表传进来的省份下拉框的name值，
		cname代表传进来的城市下拉框的name值
		sf代表传进来的省份值
		cs代表传进来的城市值
	*/
	//定义省份数组
	var city=["成都市","自贡市","攀枝花市","泸州市","德阳市","绵阳市","广元市","遂宁市","内江市"," 乐山市","南充市",
				  "眉山市","宜宾市","广安市","达州市","雅安市","巴中市","资阳市","阿坝藏族羌族自治州","甘孜藏族自治州","凉山彝族自治州","其它"];
				/*
					省份下拉框
				*/	
					document.write('<select style=" width:150px; height:30px; font-size:14px;" id="city" onchange="select_city(this)" name="pro">');
							document.write('<option value="">--请选择城市--</option>');
						var a=0;
						for(var i=0;i<city.length;i++){					
							if(typeof(sf)!="undefined"){
								if(city[i]==sf){
									var sel="selected";
									a=i;
									}
								else
									var sel="";			
							}else{
								var sel="";
							}
							document.write('<option '+sel+' value="'+city[i]+'">'+city[i]+'</option>');
						}
					document.write('</select>');
					
				/*
					省份对应的城市下拉框
				*/	
					document.write('<select  style=" width:120px; height:30px;  font-size:14px;" id="coun" name="city">');
							document.write('<option value="">--请选择地区--</option>');			
					document.write('</select>');
				if(a>0){
					select_city(document.getElementById("city"),a,cs);
				}
					//
				}
function select_city(city_obj,a,cs){
	if(typeof(a)!="undefined"){
		var index=a;
	}else{
		var index=city_obj.selectedIndex-1;
	}
	var coun_obj=document.getElementById("coun");
		coun_obj.innerHTML="";
	if(index>=0){
		for(var i=0;i<coun[index].length;i++){
			if(typeof(cs)!=undefined){
				if(coun[index][i]==cs){
					var sel="selected";
				}else
					var sel="";
			}else{
				var sel="";
			}
			var option=document.createElement("option");
			var text=coun[index][i];
				option.value=text;
				option.selected=sel;
				option.innerHTML=text;
				coun_obj.appendChild(option);
			}
		}else{
			var option=document.createElement("option");
				option.innerHTML="--请选择地区--";
				coun_obj.appendChild(option);
	}
	
}	